package cc.wsyw126.java.nowcoder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

/**
 * Created by Administrator on 2017/4/12.
 */

/**
 * 测试用例:
 4
 abcd
 abac
 aabc
 bacd

 对应输出应该为:

 2

 你的输出为:

 1
 */
public class StringClassification {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            int n = Integer.parseInt(s);
            int count = 0;
            HashMap<Character, ArrayList<Integer>> characterArrayListHashMap = new HashMap<>();
            while (n-- >0) {
                String s1 = scanner.nextLine();
                boolean flag = true;
                for (int i = 0; i < s1.length(); i++) {
                    if (characterArrayListHashMap.get(s1.charAt(i)) == null) {
                        getPut(count, characterArrayListHashMap, s1);
                        flag = false;
                        count++;
                        break;
                    }
                }
                if (flag == true) {
                    ArrayList<Integer> integers = characterArrayListHashMap.get(s1.charAt(0));
                    for (int i = 1; i < s1.length(); i++) {
                        ArrayList<Integer> integers1 = characterArrayListHashMap.get(s1.charAt(i));
                        integers.retainAll(integers1);
                        if (integers.size() == 0) {
                            getPut(count, characterArrayListHashMap, s1);
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }

    private static void getPut(int count, HashMap<Character, ArrayList<Integer>> characterArrayListHashMap, String s1) {
        for (int j = 0; j < s1.length(); j++) {
            ArrayList<Integer> integers = characterArrayListHashMap.get(s1.charAt(j));
            if (integers == null) {
                ArrayList<Integer> integers1 = new ArrayList<>();
                integers1.add(count);
                characterArrayListHashMap.put(s1.charAt(j), integers1);
            } else {
                integers.add(count);
            }
        }
    }
}
